package getIntersectionNode;

public class Solution {
      public class ListNode {
      int val;
      ListNode next;
      ListNode(int x) {
          val = x;
          next = null;
      }
  }
    public ListNode getIntersectionNode(ListNode headA, ListNode headB) {
        //
        ListNode pA = headA;
        ListNode pB = headB;
        while (pA!=pB) {
            pA = pA == null?pB:pA.next;
            pB = pB == null?pA:pB.next;
        }
        return pA;
    }
}
